//在该文件中， 所有的API接口进行统一的管理

//最新的请求地址： http://gmall-h5-api.atguigu.cn

import mockReq from "./mockRequest";
import requests from "./request";

export const GetCategoryList = () =>
  requests.get(
    "/product/getBaseCategoryList",
    (resolve) => { },
    (reject) => { }
  ); //获取三级菜单的内容
export const GetSearchList = (params) => requests.post("/list", params); //获取商品信息List
export const GetGoodsInfo = (skuId) => requests.get(`/item/${skuId}`); //获取商品详细信息
export const PostAddOrUpdateShopCar = (skuid, skuNum) =>
  requests.post(`/cart/addToCart/${skuid}/${skuNum}`); //添加购物车或更改购物车中的商品数量
export const GetShopCarList = () => requests.get("/cart/cartList"); //获取购物车列表
export const DeleteShopCarGoodsById = (skuId) =>
  requests.delete(`cart/deleteCart/${skuId}`); //根据Id删除购物车中的商品
export const PostEditShopCarGoodsIsChecked = (skuId, isChecked) =>
  requests.get(`cart/checkCart/${skuId}/${isChecked}`);


export const reqGetCode = (phone) => requests.get(`user/passport/sendCode/${phone}`) //获取验证码
export const reqRegister = (userInfo) => requests.post('/user/passport/register', userInfo) //用户注册
export const reqUserInfo = () => requests.get('user/passport/auth/getUserInfo') //获取用户信息

export const reqLogin = (phone, password) => requests.post('user/passport/login', { phone, password }) //登录
export const reqLogout = () => requests.get('user/passport/logout')  //退出登录

//获取用户地址信息接口：/api/user/userAddress/auth/findUserAddressList    get请求
export const reqUserAddressList = () => requests.get('user/userAddress/auth/findUserAddressList');
//获取订单交易页信息： /api/order/auth/trade        get
export const reqTradeInfo = () => requests.get('order/auth/trade');

export const reqSubmitOrder = (tradeNo, data) => requests.post(`order/auth/submitOrder?tradeNo=${tradeNo}`, data); //点击提交订单按钮
export const reqGetOrderPayInfo = (orderId) => requests.get(`payment/weixin/createNative/${orderId}`); //获取订单支付信息
export const reqGetPayStatus = (orderId) => requests.get(`payment/weixin/queryPayStatus/${orderId}`); //获取支付订单的状态
//获取我的订单列表 ：  /api/order/auth/{page}/{limit}     get
export const reqGetorderList = (page, limit) => requests.get(`order/auth/${page}/${limit}`);

export const GetBannerList = () =>
  mockReq.get(
    "/banners",
    (resolve) => { },
    (reject) => { }
  );
export const GetFloorList = () =>
  mockReq.get(
    "/floors",
    (resolve) => { },
    (reject) => { }
  );
